# @Desc    : life schedule
# @Author  : meihongliang  
# @Time    : 2025-03-22 13:33
from datetime import datetime

import pandas as pd


class Item:
    def __init__(self, **kwargs):
        self.no = kwargs.get('no')
        self.name = kwargs.get('name')
        self.size = kwargs.get('size')
        self.price = kwargs.get('price')
        self.color = kwargs.get('color')
        self.model = kwargs.get('model')
        self.time_of_year = kwargs.get('time_of_year')
        self.start_month = kwargs.get('start_month')
        self.finish = kwargs.get('finish')

    def is_current_month_start(self):
        current_month = datetime.now().month
        if str(current_month) in str(self.start_month):
            return True
        else:
            return False


def check_item():
    # 实例化
    df = pd.read_excel('./schedule.xlsx', sheet_name='Sheet1')
    for index, row in df.iterrows():
        # 将每一行数据实例化为 Item 对象
        item = Item(
            no=row['no'],
            name=row['name'],
            size=row['size'],
            price=row['price'],
            color=row['color'],
            model=row['model'],
            time_of_year=row['time_of_year'],
            start_month=row['start_month'],
            finish=row['finish']
        )

        if float(item.time_of_year) > 0:
            print(
                f'\t年度轮换项目={item.name},价格={item.price},型号={item.model},每年轮换次数={item.time_of_year},轮换月份={item.start_month}')

        # 判断当前月份是否是 start_month
        if item.is_current_month_start():
            print()
            print(f"\t周期轮换,项目({item.name}) 本月需要处理此项 ")
            print(f'\t轮换项目={item.name},价格={item.price},型号={item.model},每年轮换次数={item.time_of_year}')


if __name__ == '__main__':
    print(f'现在是: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}')
    check_item()
